﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Web.UI.WebControls;
using ASPNETVN.PORTAL.Components.Helpers;
using ASPNETVN.PORTAL.Components.UI;
using ASPNETVN.PORTAL.Modules.CMS.Components;
using System.Collections;
using ASPNETVN.PORTAL.Components.Configuration;

namespace ASPNETVN.PORTAL.Modules.CMS.HOME.Controls
{
    public partial class Style1 : ModulePage
    {
        protected string GetUrl(int itemID)
        {
            Guid tabID = Guid.Empty;
            PortalDataSet ds = PortalConfiguration.GetPortalDataSet();

            foreach (PortalDataSet.TabRow tab in ds.Tab.Rows)
            {
                foreach (PortalDataSet.ModuleRow module in tab.GetModuleRows())
                {
                    if (module.ID == new Guid(this.Settings["CMS.ModuleID"].ToString()))
                    {
                        return string.Format("~/Default.aspx?tabid={0}&mid={1}&itemid={2}&page=detail", tab.ID, module.ID, itemID);
                    }
                }
            }
            return string.Format("~/Default.aspx");
        }



        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack == false)
            {
                Hashtable settings = this.Settings;
                Guid moduleID = new Guid(settings["CMS.ModuleID"].ToString());
                
                // Get one type item for home.
                Repeater1.DataSource = ASPNETVN.PORTAL.Modules.CMS.Components.Item.GetItemsByDisplayType(moduleID, "ONE");
                Repeater1.DataBind();

                // Get two type item for home.
                Repeater2.DataSource = ASPNETVN.PORTAL.Modules.CMS.Components.Item.GetItemsByDisplayType(moduleID, "TWO");
                Repeater2.DataBind();
            }
        }
    }
}